package com.spark.util.example

import com.spark.util.client.Neo4jClient
import com.spark.util.utils.PropertiesUtil

object Neo4jExample {

  def main(args: Array[String]): Unit = {

    PropertiesUtil.load("dev.properties")
    val url = PropertiesUtil.getString("neo4j.url")
    val username = PropertiesUtil.getString("neo4j.username")
    val password =  PropertiesUtil.getString("neo4j.password")

    val neo4j = Neo4jClient(url, username, password)
    //CREATE CONSTRAINT ON (a:Table) ASSERT a.name IS UNIQUE
    //DROP CONSTRAINT ON (a:Table) ASSERT a.name IS UNIQUE
    //neo4j.removeLabel("Table")
    neo4j.useSession{ session=>
      val res = session.run(
        """
          |MATCH (n:Table)-[r:TableBlood*]->(m:Table)
          |WHERE m.name = 'liuxinpei3'
          |RETURN n as source,m as target,r as relation_list
          |""".stripMargin)
      println(res.next().asMap())
    }
    neo4j.close()
  }

}
